/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

/**
 * <p>Project: app2022 - For1
 * <p>Powered by webrx On 2022-01-08 08:52:51
 *
* @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class For1 {
    public static void main(String[] args) {
        System.out.printf("%02x", 255);

        for (int i = 0; i < 5; i++) {
            if (true) continue;
            System.out.println(i);
        }
    }

    public static void f8(String[] args) {
        //for计数循环语句 break终止循环  continue 继续循环
        for (int i = 0; i < 20; i++) {
            if (i % 2 != 0) continue;//结束这一次循环，立即开始下次一循环开始
            System.out.println(i);
            if (i > 10) {
                break;//跳出循环语句（终止循环语句）
            }
        }

    }

    public static void f7(String[] args) {
        //公鸡一个五块钱，母鸡一个三块钱，小鸡三个一块钱，现在要用一百块钱买一百只鸡，问公鸡、母鸡、小鸡各多少只
        for (int i = 0; i <= 100 / 5; i++) {
            for (int i1 = 0; i1 <= 100 / 3; i1++) {
                for (int i2 = 0; i2 <= 100; i2++) {
                    int a = i;
                    int b = i1;
                    int c = i2;
                    if ((a + b + c) == 100 && (a * 5 + b * 3 + c / 3) == 100 && c % 3 == 0) {
                        System.out.printf("公鸡：%d只，母鸡：%d只，小鸡：%d只。%n", a, b, c);
                    }
                }
            }
        }
    }

    public static void f6(String[] args) {
        for (int a = 1; a <= 9; a++) {
            for (int b = 1; b <= a; b++) {
                System.out.printf("%2d×%d = %2d", a, b, a * b);
            }
            System.out.printf("%n");
        }
    }

    public static void f5(String[] args) {
        int s = 15;
        for (int i = 1; i <= 15; i += 2) {
            --s;
            for (int i1 = 0; i1 < s; i1++) System.out.print(" ");
            for (int j = 1; j <= i; j++) System.out.print("*");
            System.out.println();
        }
        for (int i = 13; i > 0; i -= 2) {
            ++s;
            for (int i1 = 0; i1 < s; i1++) System.out.print(" ");
            for (int j = 1; j <= i; j++) System.out.print("*");
            System.out.println();
        }
    }

    public static void f4(String[] args) {
        //1+2+3+...+100 = ?计算求和
        int sum = 0;
        for (int i = 1; i <= 100; i++) {
            sum += i;
            //sum = sum + i;
        }
        System.out.printf("1+2+3+...+100=%d%n", sum);
    }

    public static void f3(String[] args) {
        //计数型循环语句，当前知道循环次数，使用此语句非常方便
        for (int i = 6; i > 0; --i) {
            System.out.println(i);
        }
    }

    public static void f2(String[] args) {
        int i = 16;
        System.out.println(i);
        for (i = 0; i < 6; i++) {
            System.out.println(i);
            //i = 3;
        }
        System.out.println(i);
    }
}
